/**
 * Copyright(c) 2013 Jade Techonologies Co., Ltd.
 *
 * History:
 *   13-4-14 下午3:57 Created by dwzhang
 */
package com.jade.framework.base.criterion.expression;

/**
 * Constrains a property to between two values.
 *
 * @author dwzhang
 * @version 1.0 13-4-14 下午3:57
 */
public class BetweenExpression extends AbstractPropertyExpression
{
    private Object low;
    private Object high;

    /**
     * 构造函数.
     *
     * @param entityName 实体名称
     * @param propName   属性名称
     * @param low        区间中的较小值
     * @param high       区间中的较大值
     */
    public BetweenExpression(String entityName, String propName, Object low, Object high)
    {
        super(entityName, propName);
        this.low = low;
        this.high = high;
    }

    /**
     * 构造函数.
     *
     * @param propName 属性名称
     * @param low      区间中的较小值
     * @param high     区间中的较大值
     */
    public BetweenExpression(String propName, Object low, Object high)
    {
        super(propName);
        this.low = low;
        this.high = high;
    }

    public Object getLow()
    {
        return low;
    }

    public Object getHigh()
    {
        return high;
    }

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append(getFullName());
        sb.append(" BETWEEN ").append(low).append(" AND ").append(high);
        return sb.toString();
    }
}
